<?php
/* ******************************
 *	SEOoooY aJax actions
 * ******************************
 */

include('../../includes/classes/core.php');
$action = $_REQUEST['act'];
$data = '';

switch ($action) {
	case 'category_name':
        $rResult = mysql_query("SELECT DISTINCT production.production_category as id,
								production.`production_category`
						FROM    production
						WHERE   actived = 1 ");

		$data = array();
		$s = 0;

		while($aRow = mysql_fetch_array($rResult))
		{
			for ( $i = 0 ; $i < 1; $i++ )
			{
				/* General output */
				$data[$s] = htmlspecialchars_decode($aRow[$i], ENT_QUOTES);
				$s++;
			}
		}

		break;
	case 'production_name':
		$prod_cat = $_REQUEST['prod_cat'];
		
		$rResult = mysql_query("SELECT DISTINCT production.brand as id,
										production.`brand`
								FROM    production
								WHERE   actived = 1 AND production.production_category='$prod_cat'");
		
		$data = array();
		$s = 0;
		
		while($aRow = mysql_fetch_array($rResult))
		{
			for ( $i = 0 ; $i < 1; $i++ )
			{
				/* General output */
				$data[$s] = htmlspecialchars_decode($aRow[$i], ENT_QUOTES);
				$s++;
			}
		}
		
		break;
	case 'brand_name':
		$prod_brand = $_REQUEST['prod_brand'];
		$prod_cat = $_REQUEST['prod_cat'];
		
		$rResult = mysql_query("
				SELECT DISTINCT production.`name` as id,
											production.`name`
							FROM    production
							WHERE   actived = 1 AND production.production_category='$prod_cat' AND production.brand='$prod_brand'");
	
		$data = array();
		$s = 0;
	
		while($aRow = mysql_fetch_array($rResult))
		{
			for ( $i = 0 ; $i < 1; $i++ )
			{
				/* General output */
				$data[$s] = htmlspecialchars_decode($aRow[$i], ENT_QUOTES);
				$s++;
			}
		}
	
		break;
    default:
       echo 'Action is Null';
}


echo json_encode($data);

?>